
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel=stylesheet href='include/hoj.css' type='text/css'>
</head>
<body>
<center>
<div style="width:90%; text-align:left">
<img src="image/logo.png"/>
</div>
<table width=96%> 
	<tr align="center" class='hd' valign="top">
				<th><a href="faqs.php">F.A.Qs</a></th>
		<th><a href="./bbs.php">Web Board</a></th>
		<th><a href="./">Home</a></th>
		<th><a href="./problemset.html">ProblemSet</a></th>
		<th><a href="./status.php">Status</a></th>
		<th><a href="./ranklist.php">Ranklist</a></th>
		<th><a href="./contest.php">Contest</a></th>
		<th><a href=loginpage.php>Login</a></th><th><a href=registerpage.php>Register</a></th>	</tr>
</table>
</center>
<center>
<div class="notice">
	<div>
		<B>Notice:</B>鉴于种种原因，本OJ自下周星期一（3月5号）开始不再全面开放，请各位做好善后事宜，谢谢合作。	</div>
</div>
</center>
</div>
<title>Problem 2230. -- [Neerc2006]Fool's Game
</title><center><h2>2230: [Neerc2006]Fool's Game
</h2><span class=green>Time Limit: </span>30 Sec&nbsp;&nbsp;<span class=green>Memory Limit: </span>259 MB<br><span class=green>Submit: </span>5&nbsp;&nbsp;<span class=green>Solved: </span>2<br>[<a href='submitpage.php?id=2230'>Submit</a>][<a href='problemstatus.php?id=2230'>Status</a>][<a href='bbs.php?id=2230'>Discuss</a>]</center><h2>Description</h2><div class=content>有一种纸牌游戏叫”Fool’s Game”，其规则是这样的：
&#61548;	使用4种花色的6,7,8,9,10,J,Q,K,A共36张牌，牌的大小按照从左到右依次变大。有一种花色是主牌，主牌比所有副牌都大。
&#61548;	打牌的过程双方都可以看到对方的牌，以及桌上的牌，以及已经被丢弃的牌。
&#61548;	在一轮游戏中，由一方出牌，一方跟牌。一轮游戏进程如下：
&#61550;	首先，出牌方甩出若干相同大小的牌。
&#61550;	当出牌方甩出牌之后，跟牌方应该对每一张新出的牌都用一张自己的牌跟上去，这张跟上去的牌必须比被跟的牌大。
&#61550;	如果桌上所有牌都成功被跟，出牌方必须在甩出至少一张牌，且甩出的牌的分值必须在桌上已经出现过。
&#61550;	如果某一轮出牌方甩牌之后，跟牌方不能或不愿意跟掉这些牌，则出牌方还可以选择再甩出若干张牌（这些牌的分值必须在桌上已经出现过）。然后，出牌方赢得这一轮，桌上所有牌归该跟牌方所有。双方的角色不变，进入下一轮游戏。
&#61550;	如果某一轮跟牌方完成跟牌之后，出牌方不能或不愿意再甩牌，则跟牌方赢得这一轮游戏。桌上所有牌被丢弃，双方交换出牌、跟牌角色后进入下一轮游戏。
&#61550;	任何一个时刻，桌上未被跟的牌的数量不能超过跟牌方手中的牌的数量。
&#61548;	游戏的胜负这样判定：
&#61550;	如果某一轮结束之后，一方手中无牌而另一方手中有牌，则无牌的一方胜。
&#61550;	如果某一轮结束之后双方手中都无牌，则在刚刚结束的那一轮中出牌的一方获胜。
给出一开始每给人手上的牌，判断哪一方获胜。（第一个人在第一轮中出牌）。
限制
&#61548;	每个人手中的牌的数量不超过6张。
</div><h2>Input</h2><div class=content>The first line of the input file contains n1 and n2 — the number of cards that each of the players has in the beginning of the round (1 ≤ n1, n2 ≤ 6), and the trump suit (suit is specified using one letter: ‘S’ for spades, ‘C’ for clubs, ‘D’ for diamonds, ‘H’ for hearts).

The second line contains n1 card descriptions — the cards of the first player. Each card is specified by its rank (‘6’…‘9’, ‘T’ for 10, ‘J’ for Jack, ‘Q’ for Queen, ‘K’ for King, ‘A’ for Ace) followed by its suit. The third line contains n2 card descriptions — the cards of the covering player. The first player is the starting player in the first round.

All cards in players’ hands are different.

</div><h2>Output</h2><div class=content>Output “FIRST” if the first player wins the game, or “SECOND” if the second player does.

</div><h2>Sample Input</h2>
			<div class=content><span class=sampledata>sample input #1<br />
2 2 S<br />
KC AD<br />
6S 7S<br />
<br />
sample input #2<br />
2 2 D<br />
KC AD<br />
6S 7S<br />
<br />
sample input #3<br />
4 5 C<br />
AS 6S 7S 8S<br />
9S TS JS QS KS<br />
<br />
sample input #4<br />
3 2 C<br />
6H JS JD<br />
AD 6C<br />
</span></div><h2>Sample Output</h2>
			<div class=content><span class=sampledata>sample output #1<br />
SECOND<br />
<br />
sample output #2<br />
FIRST<br />
<br />
sample output #3<br />
SECOND<br />
<br />
sample output #4<br />
FIRST<br />
</span></div><h2>HINT</h2>
			<div class=content><p></p></div><h2>Source</h2>
			<div class=content><p><a href='problemset.html?search=Neerc2006'>Neerc2006</a></p></div><center>[<a href='submitpage.php?id=2230'>Submit</a>][<a href='problemstatus.php?id=2230'>Status</a>][<a href='bbs.php?id=2230'>Discuss</a>]</center>﻿<br>

<a href="./"><span class=red>HOME</span></a>
<a href="javascript:history.go(-1)"><span class=red>Back</span></a>

<hr>
<center>
	<div class="footer">
			<a href=setlang.php?lang=ko>한국어</a>&nbsp;
		<a href=setlang.php?lang=cn>中文</a>&nbsp;
		<a href=setlang.php?lang=fa>فارسی</a>&nbsp;
		<a href=setlang.php?lang=en>English</a>&nbsp;
		<a href=setlang.php?lang=th>ไทย</a>
	<br>		<div>版权所有 &copy;2008-2012 WaterPark Organization. | <script src="http://s21.cnzz.com/stat.php?id=2982771&web_id=2982771" language="JavaScript"></script>
</div>
		<div>Based on opensource project <a href="http://hustoj.googlecode.com">hustoj</a>.</div>
	</div>
</center>
</body>
</html>
